<template>
	<view>
		<button class="btn-login" open-type="getUserInfo" lang="zh_CN" @getuserinfo="GetUserInfo">
			<slot :login="login"/>
		</button>
	</view>
</template>


<script>
    export default {
		components: {  },
		name: 'login',
		props: {
		},
		data() {
			return {
				login:false
			}
		},
		created(e) {
			if(this.$users.ID==undefined)
			{
				this.GetUserInfo();
			}else{
				this.login = true;
			}
		},
		methods: {
			GetUserInfo(res){
				if(this.$users.ID!=undefined) return false;
				
				if(res==undefined || res.detail.errMsg=="getUserInfo:ok"){
					var th = this;
					this.$users.login(function(isSuccess){
						th.login = isSuccess;
					});
				}
			}
		}
	}
</script>

<style lang="scss">
	.btn-login{
		background-color: unset;
		text-align: unset;
		padding: unset;
		margin: unset;
		line-height: unset;
		color: unset;
		border-radius: unset;
        position: unset;
		display: unset;
	}
</style>